import { ElMessage } from 'element-plus';
import request from './useRequests';
export default function findForget() {
  async function forget(email: string, code: string) {
    console.log(email);
    console.log(code);
    try {
      const res = await request.post('auth/forget', {
        email: email,
        code: code,
      });
      console.log(res.data);
      if (res.status) {
        ElMessage({
          showClose: true,
          message: '找回成功，密码为123456',
          type: 'success',
        });
      } else {
        ElMessage({
          showClose: true,
          message: '验证码与邮箱无法匹配',
          type: 'error',
        });
      }
    } catch (e: any) {
      ElMessage({
        showClose: true,
        message: '发送失败',
        type: 'error',
      });
    }
  }

  return {
    forget,
  };
}
